package com.zhai.test.trigger;

import com.alibaba.fastjson.JSON;
import com.zhai.trigger.dto.*;
import com.zhai.trigger.http.RaffleActivityController;
import com.zhai.trigger.http.RaffleStrategyController;
import com.zhai.types.model.Response;
import lombok.extern.slf4j.Slf4j;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;
import java.util.List;
import java.util.concurrent.CountDownLatch;

/**
 * @Description: 抽奖外部测试类
 * @ClassName: RaffleActivityControllerTest
 * @Author: zhaiyongxin
 * @Date: 2025/3/27 15:49
 * @Version: 1.0
 */
@SpringBootTest
@RunWith(SpringRunner.class)
@Slf4j
public class RaffleActivityControllerTest {

    @Resource
    private RaffleActivityController raffleActivityController;

    @Before
    public void test_armory() {
        Response<Boolean> response = raffleActivityController.armory(100301L);
        log.info("测试结果：{}", JSON.toJSONString(response));
    }

    @Test
    public void test_draw() throws InterruptedException {
        ActivityDrawRequestDTO request = new ActivityDrawRequestDTO();
        request.setUserId("zhaiyongxin");
        request.setActivityId(100301L);
        Response<ActivityDrawResponseDTO> response = raffleActivityController.draw(request);

        log.info("请求参数：{}", JSON.toJSONString(request));
        log.info("测试结果：{}", JSON.toJSONString(response));
        new CountDownLatch(1).await();
    }

    @Test
    public void test_calendarSignRebate() throws InterruptedException {
        Response<Boolean> response = raffleActivityController.calendarSignRebate("zhaiyongxin");
        log.info("测试结果：{}", JSON.toJSONString(response));
        new CountDownLatch(1).await();
    }

    @Test
    public void test_isCalendarSignRebate(){
        Response<Boolean> response = raffleActivityController.isCalendarSignRebate("zhaiyongxin");
        log.info("测试结果：{}", JSON.toJSONString(response));
    }

    @Test
    public void test_queryUserActivityAccount(){
        UserActivityAccountRequestDTO userActivityAccountRequestDTO = new UserActivityAccountRequestDTO();
        userActivityAccountRequestDTO.setUserId("zhaiyongxin");
        userActivityAccountRequestDTO.setActivityId(100301L);
        Response<UserActivityAccountResponseDTO> response = raffleActivityController.queryUserActivityAccount(userActivityAccountRequestDTO);
        log.info("测试结果：{}", JSON.toJSONString(response));
    }
}
